import storage from 'good-storage'
import {SET_TOKEN,SETTING,NETWORK} from '../mutation-types'
// initial state
const state = {
  token: storage.get('token') ? storage.get('token') : {},
  setting: storage.get('setting') ? storage.get('setting') : {},
  network: storage.get('network')===false ? false : true,
}
// getters
const getters = {}

// actions
const actions = {  
}
// mutations
const mutations = { 
  [SET_TOKEN](state, data) {    
    storage.set('token',data)
    state.token = data
  },
  [SETTING](state, data) {    
    storage.set('setting',data)
    state.setting = data
  },
  [NETWORK](state, data) {    
    storage.set('network',data)
    state.network = data
  }
}

export default {
  //namespaced: true,
  state,
  getters,
  actions,
  mutations
}
